package by.averianov.discounta.datamodel;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import by.averianov.discounta.datamodel.compositekeys.ProductPK;

@Entity
@IdClass(ProductPK.class)
public class Product extends AbstractEntity {

	@Id
	//@Column(name = "product_id", insertable = false, updatable = false)
    private Long id;
	
	@Column
	@NotNull
	@Size(max = 50)
	private String nameProduct;
	
	@Column
	@NotNull
	@Max(value = 99999999)
	@Min(value = 0)
	private Long priceProduct;
	
	@Column
	@NotNull
	private Boolean discountStatus;
	
	@Column
	@NotNull
	@Max(value = 999)
	@Min(value = 0)
	private Long countProduct;
	
	@Column
	@NotNull
	private Long checkoutCounter;

	/*@Id
	@Column//(name = "shop_id", insertable = false, updatable = false)
	private Long shopId;*/
	
	@Id
	@ManyToOne(fetch = FetchType.EAGER, targetEntity = Shop.class)
	//@JoinColumn(name = "shop_id")
	private Shop shop;
	
	public Product() {
	}

	public Product(Long id, Shop shop) {
	    this.id = id;
	    //this.shopId = shop.getId();
	    this.shop = shop;
	}
	
	/*public Long getShopId() {
		return shopId;
	}

	public void setShopId(Long shopId) {
		this.shopId = shopId;
	}*/

	public String getNameProduct() {
		return nameProduct;
	}

	public void setNameProduct(String nameProduct) {
		this.nameProduct = nameProduct;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getPriceProduct() {
		return priceProduct;
	}

	public void setPriceProduct(Long priceProduct) {
		this.priceProduct = priceProduct;
	}

	public Boolean getDiscountStatus() {
		return discountStatus;
	}

	public void setDiscountStatus(Boolean discountStatus) {
		this.discountStatus = discountStatus;
	}

	public Long getCountProduct() {
		return countProduct;
	}

	public void setCountProduct(Long countProduct) {
		this.countProduct = countProduct;
	}

	public Long getCheckoutCounter() {
		return checkoutCounter;
	}

	public void setCheckoutCounter(Long checkoutCounter) {
		this.checkoutCounter = checkoutCounter;
	}

	public Shop getShop() {
		return shop;
	}

	public void setShop(Shop shop) {
		this.shop = shop;
	}
	
}
